package com.evl.wxpay.util.paytype.verify;

import java.util.HashMap;
import java.util.Map;

import com.evl.common.persistence.model.TrainOrder;
import com.evl.common.persistence.model.WxPayRecord;
import com.evl.core.vo.BaseResultVo;
import com.evl.wxpay.util.IWXPay;
import com.evl.wxpay.util.paytype.PayType;

/**
 * 微信小程序支付订单查询
 * @author dangsheng
 *
 */
public class QueryVerify extends Verify{
	
	/**
	 * 校验数据，添加请求参数
	 */
	@Override
	public Map required(Object obj) throws Exception{
		TrainOrder order = (TrainOrder)obj;
		Map map = new HashMap();
		map.put("out_trade_no", order.getOrderNo());
		return map;
	}
	
	/**
	 * 记录日志
	 */
	@Override
	public WxPayRecord logRecord(WxPayRecord wxPayRecord,Object obj){
		TrainOrder order = (TrainOrder)obj;
		wxPayRecord.setOrderId(order.getId());
		return wxPayRecord;
	}

	@Override
	public Map request(IWXPay wXPay,PayType payType) throws Exception {
		//调用微信支付的接口方法
		return wXPay.orderQuery(payType.getReqData(), payType);
	}

	@Override
	public String getOpenId(PayType payType) {
		return ((TrainOrder)payType.getObj()).getCreateId();
	}

	@Override
	public BaseResultVo sendMessage(PayType payType) {
		return null;
	}

}
